import process from 'node:process';
import { fileURLToPath, URL } from 'node:url';
import {defineConfig, loadEnv} from 'vite';
import { setupVitePlugins } from './build/plugins';

// https://vitejs.dev/config/
export default defineConfig(configEnv => {
  const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as Env.ImportMeta;
  return {
    base: viteEnv.VITE_BASE_URL,
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    },
    plugins: setupVitePlugins(viteEnv),
    define: {
        BUILD_TIME: JSON.stringify(new Date().toISOString())
    },
    server: {
      host: '0.0.0.0',
      port: 9527,
      open: false
    }
  }
})
